package com.ykdl.member.kid.image;

import android.content.Context;
import android.content.res.Resources;

import com.ykdl.member.kid.R;

public final class ImageProcessorFactory {
	private static ImageProcessor portraitProcessor;
	private static ImageProcessor smallPortraitProcessor;
	private static final Object lock = new Object();

	public static ImageProcessor getPortraitProcessor(Context context) {
		synchronized (lock) {
			if (portraitProcessor == null) {
				Resources resource = context.getResources();
				portraitProcessor = new RoundRectImageProcessor(
						(int) resource.getDimension(R.dimen.portrait_width),
						(int) (resource.getDimension(R.dimen.portrait_height)),
						resource.getDimension(R.dimen.portrait_radius));
			}
		}
		return portraitProcessor;
	}

	public static ImageProcessor getSmallPortraitProcessor(Context context) {
		synchronized (lock) {
			if (smallPortraitProcessor == null) {
				Resources resource = context.getResources();
				smallPortraitProcessor = new RoundRectImageProcessor(
						(int) resource
								.getDimension(R.dimen.portrait_small_width),
						(int) (resource
								.getDimension(R.dimen.portrait_small_height)),
						resource.getDimension(R.dimen.portrait_radius));
			}
		}
		return smallPortraitProcessor;
	}
}
